/**
 * 
 */
package stationGUI;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 * @author iggardne
 *
 */
public class ProgressPanel extends JPanel implements ChangeListener {

  

  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  private JSlider slider;
  
  /**
   * 
   */
  public ProgressPanel(ClientNode n) {
    setBackground(Station.BACKGROUND_COLOR);
    
    //adding the progress slider!!! maybe move to own panel
    System.out.println("Creating progress slider with total: "+n.me.total);
    slider=new JSlider(JSlider.HORIZONTAL,0,n.me.total,0);
    slider.setEnabled(true);
    slider.addChangeListener(this);
    slider.setPreferredSize(new Dimension(300,100));
    slider.setBackground(Station.BACKGROUND_COLOR);
    add(BorderLayout.SOUTH,slider);
  }
  
  
  public void updateSlider(int n) {
    System.out.println("Setting progress to: "+n);
    slider.setValue(n);

    repaint();
    slider.repaint();
    repaint();
    slider.updateUI();
    slider.repaint();
    repaint();
  }
  
  /** Listen to the slider. */
  public void stateChanged(ChangeEvent e) {
      JSlider source = (JSlider)e.getSource();
      source.revalidate();
      slider.setSize(300,100);
      source.validate();
      //System.out.println(source.isLightweight());
  }

}
